﻿namespace Sidvall.AuthorizationManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class AuthorizationScopeExport : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport
    {
        #region Public Members

        #region AuthorizationScopeExportId

        private System.Nullable<long> _AuthorizationScopeExportId;
        partial void OnBeforeAuthorizationScopeExportIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterAuthorizationScopeExportIdPropertyChanged();
        public System.Nullable<long> AuthorizationScopeExportId
        { 
            get
            {
                return _AuthorizationScopeExportId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeExportId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _AuthorizationScopeExportId);
                    OnBeforeAuthorizationScopeExportIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeExportId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeExportIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region AuthorizationScopeId

        private long _AuthorizationScopeId;
        partial void OnBeforeAuthorizationScopeIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterAuthorizationScopeIdPropertyChanged();
        public long AuthorizationScopeId
        { 
            get
            {
                return _AuthorizationScopeId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _AuthorizationScopeId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _AuthorizationScopeId);
                    OnBeforeAuthorizationScopeIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("AuthorizationScopeId", eventData.Value, true, true);
                        OnAfterAuthorizationScopeIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region CreateMissingFile

        private bool _CreateMissingFile;
        partial void OnBeforeCreateMissingFilePropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCreateMissingFilePropertyChanged();
        public bool CreateMissingFile
        { 
            get
            {
                return _CreateMissingFile;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _CreateMissingFile = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CreateMissingFile);
                    OnBeforeCreateMissingFilePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("CreateMissingFile", eventData.Value, true, true);
                        OnAfterCreateMissingFilePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region FilePath

        private string _FilePath;
        partial void OnBeforeFilePathPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFilePathPropertyChanged();
        public string FilePath
        { 
            get
            {
                return _FilePath;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _FilePath = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FilePath);
                    OnBeforeFilePathPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("FilePath", eventData.Value, true, true);
                        OnAfterFilePathPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IncludeResourceItems

        private bool _IncludeResourceItems;
        partial void OnBeforeIncludeResourceItemsPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIncludeResourceItemsPropertyChanged();
        public bool IncludeResourceItems
        { 
            get
            {
                return _IncludeResourceItems;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IncludeResourceItems = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IncludeResourceItems);
                    OnBeforeIncludeResourceItemsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IncludeResourceItems", eventData.Value, true, true);
                        OnAfterIncludeResourceItemsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IncludeUserItems

        private bool _IncludeUserItems;
        partial void OnBeforeIncludeUserItemsPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIncludeUserItemsPropertyChanged();
        public bool IncludeUserItems
        { 
            get
            {
                return _IncludeUserItems;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IncludeUserItems = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IncludeUserItems);
                    OnBeforeIncludeUserItemsPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IncludeUserItems", eventData.Value, true, true);
                        OnAfterIncludeUserItemsPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IsEnabled = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                    OnBeforeIsEnabledPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IsEnabled", eventData.Value, true, true);
                        OnAfterIsEnabledPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region XmlNode

        private string _XmlNode;
        partial void OnBeforeXmlNodePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterXmlNodePropertyChanged();
        public string XmlNode
        { 
            get
            {
                return _XmlNode;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _XmlNode = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _XmlNode);
                    OnBeforeXmlNodePropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("XmlNode", eventData.Value, true, true);
                        OnAfterXmlNodePropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        
        public AuthorizationScope AuthorizationScope { get; set; }
        #region LoadAuthorizationScopeAsync

        public async System.Threading.Tasks.Task<AuthorizationScope> LoadAuthorizationScopeAsync()
        {
            return await LoadAuthorizationScopeAsync(false, true, null, null, null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScope> LoadAuthorizationScopeAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeExportManager.LoadAuthorizationScopeAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters).ConfigureAwait(false);

            return this.AuthorizationScope;
        }
        public AuthorizationScope LoadAuthorizationScope(AuthorizationScope item)
        {
            LoadInstanceField("AuthorizationScope", item, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public AuthorizationScopeExport Copy()
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Copy(this);
        }
        public AuthorizationScopeExport Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport item)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Import(this, item);
        }
        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Import(this, item, settings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeExport> SaveItemAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeExportManager.SaveItemAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeExport> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeExportManager.SaveItemAsync(this, mode).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeExport> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeExportManager.SaveItemAsync(this, settings).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeExport> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.DataPortal.AuthorizationScopeExportManager.SaveItemAsync(this, settings, strategyContext, objectParameters).ConfigureAwait(false);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Initialize(this, settings);
        }

        #endregion

        #region IAuthorizationScopeExport Members

        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.AuthorizationScopeExportId
        {
            get
            {
                return this._AuthorizationScopeExportId;
            }
            set
            {
                this._AuthorizationScopeExportId = value;
            }
        }
        long global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.AuthorizationScopeId
        {
            get
            {
                return this._AuthorizationScopeId;
            }
            set
            {
                this._AuthorizationScopeId = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.CreateMissingFile
        {
            get
            {
                return this._CreateMissingFile;
            }
            set
            {
                this._CreateMissingFile = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.FilePath
        {
            get
            {
                return this._FilePath;
            }
            set
            {
                this._FilePath = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.IncludeResourceItems
        {
            get
            {
                return this._IncludeResourceItems;
            }
            set
            {
                this._IncludeResourceItems = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.IncludeUserItems
        {
            get
            {
                return this._IncludeUserItems;
            }
            set
            {
                this._IncludeUserItems = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.XmlNode
        {
            get
            {
                return this._XmlNode;
            }
            set
            {
                this._XmlNode = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.IAuthorizationScope global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport.AuthorizationScope
        {
            get
            {
                return this.AuthorizationScope;
            }
            set
            {
                this.AuthorizationScope = (AuthorizationScope)value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScopeExport()
        {
        }
        public AuthorizationScopeExport(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public AuthorizationScopeExport(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.AuthorizationManager.SystemContext.Current.EntityFacade.AuthorizationScopeExportManager.Initialize(this);
        }

        #endregion
    }
}